package com.scuec.tourismwebsite.controller;

import com.github.pagehelper.PageInfo;
import com.scuec.tourismwebsite.entity.WeatherTip;
import com.scuec.tourismwebsite.service.WeatherTipService;
import com.scuec.tourismwebsite.vo.ViewWeatherTip;
import org.springframework.web.bind.annotation.*;

import java.util.List;
//
@RestController
@RequestMapping("/weather-tip")
@CrossOrigin
public class WeatherTipController {
    private WeatherTipService weatherTipService;

    public WeatherTipController(WeatherTipService weatherTipService) {
        this.weatherTipService = weatherTipService;
    }

    @GetMapping("/page")
    public PageInfo<ViewWeatherTip> getWeathertipPages(Integer pageNum, Integer pageSize) {
        PageInfo<ViewWeatherTip> pageInfo=weatherTipService.findWeatherTipPages(pageNum,pageSize);
        return pageInfo;
    }
    @GetMapping("/query")
    public List<ViewWeatherTip> findWeatherTip() {
        return weatherTipService.findWeatherTip();
    }


    @PostMapping("/insert")
    public Integer insertWeatherTip(@RequestBody WeatherTip weatherTip) {
        return weatherTipService.insertWeatherTip(weatherTip);
    }


    @PutMapping("/update")
    public Integer updateWeatherTip(@RequestBody WeatherTip weatherTip) {
        return weatherTipService.updateWeatherTip(weatherTip);
    }

    // 根据ID删除天气预测信息
    @DeleteMapping("/del")
    public Integer deleteWeatherTip(Integer tip_id) {
        return weatherTipService.deleteWeatherTip(tip_id);
    }

}
//1